package com.airforce.mappers;

import com.airforce.model.index_award;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface index_awardMapper {
    @Delete({
        "delete from index_award",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into index_award (id, awardname, ",
        "awardimg, awardprice, ",
        "power, createtime, ",
        "updatetime, sharebefore, ",
        "flag, orders)",
        "values (#{id,jdbcType=INTEGER}, #{awardname,jdbcType=VARCHAR}, ",
        "#{awardimg,jdbcType=VARCHAR}, #{awardprice,jdbcType=DECIMAL}, ",
        "#{power,jdbcType=DOUBLE}, #{createtime,jdbcType=TIMESTAMP}, ",
        "#{updatetime,jdbcType=TIMESTAMP}, #{sharebefore,jdbcType=TINYINT}, ",
        "#{flag,jdbcType=TINYINT}, #{orders,jdbcType=INTEGER})"
    })
    int insert(index_award record);

    @InsertProvider(type=index_awardSqlProvider.class, method="insertSelective")
    int insertSelective(index_award record);

    @Select({
        "select",
        "id, awardname, awardimg, awardprice, power, createtime, updatetime, sharebefore, ",
        "flag, orders",
        "from index_award",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="awardname", property="awardname", jdbcType=JdbcType.VARCHAR),
        @Result(column="awardimg", property="awardimg", jdbcType=JdbcType.VARCHAR),
        @Result(column="awardprice", property="awardprice", jdbcType=JdbcType.DECIMAL),
        @Result(column="power", property="power", jdbcType=JdbcType.DOUBLE),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="sharebefore", property="sharebefore", jdbcType=JdbcType.TINYINT),
        @Result(column="flag", property="flag", jdbcType=JdbcType.TINYINT),
        @Result(column="orders", property="orders", jdbcType=JdbcType.INTEGER)
    })
    index_award selectByPrimaryKey(Integer id);

    @UpdateProvider(type=index_awardSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(index_award record);

    @Update({
        "update index_award",
        "set awardname = #{awardname,jdbcType=VARCHAR},",
          "awardimg = #{awardimg,jdbcType=VARCHAR},",
          "awardprice = #{awardprice,jdbcType=DECIMAL},",
          "power = #{power,jdbcType=DOUBLE},"   ,
          "createtime = #{createtime,jdbcType=TIMESTAMP},",
          "updatetime = #{updatetime,jdbcType=TIMESTAMP},",
          "sharebefore = #{sharebefore,jdbcType=TINYINT},",
          "flag = #{flag,jdbcType=TINYINT},",
          "orders = #{orders,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(index_award record);
    @Select("select * from index_award where awardname like #{awardname}")
    List<index_award> selectByname(String awardname );

    @Select("select * from index_award  ORDER BY orders ")
    List<index_award> selectByall();

    @Select("select * from  index_award  where  sharebefore=0 or sharebefore=2")
    List<index_award>selectByBefore();

    @Select("select * from  index_award  where  sharebefore=1 or sharebefore=2")
    List<index_award>selectByafter();

    @Select("select * from index_award where awardname = #{awardname}")
    index_award selectByawardname(String awardname );
}